package com.codeoss.framework.view.renderer;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.codeoss.framework.context.YunContext;
import com.codeoss.framework.view.component.Component;
import com.codeoss.framework.view.component.Hidden;
import com.codeoss.framework.view.service.IVariableService;

@Service
public class HiddenRenderer extends CommonComponentRenderer {
	@Autowired
	private IVariableService variableService;
	protected void startRenderView(YunContext yunContext, Component component, ViewSerializeMap viewSerializeMap) {
		super.startRenderView(yunContext, component, viewSerializeMap);
		Hidden hidden = (Hidden) component;
		viewSerializeMap.put("dataField", hidden.getDataField());
	}
	
	@Override
	protected PropSerializeMap startRenderProp(YunContext yunContext, Component component, ViewPropMap viewPropMap) {
		PropSerializeMap propSerializeMap = super.startRenderProp(yunContext, component, viewPropMap);
		Hidden hidden = (Hidden) component;
		Object value=variableService.getVariableValue(yunContext, hidden.getVarName());
		propSerializeMap.put("value", value);
		return propSerializeMap;
	}
}
